package com.hyjx.framework.component.theme;

import com.hyjx.framework.common.CommonUtil;
import com.hyjx.framework.orm.dao.IBaseDao;
import com.hyjx.framework.orm.dao.Pager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * * 主题管理服务实现类
 */
@Service
@Transactional
public class ThemeServiceImpl implements ThemeService {

    @Resource
    private IBaseDao dao;

    public String queryList(ThemeModel model) {
        Pager pager = dao.getPager("theme.queryList", "theme.queryCount", model);

        return CommonUtil.getPageJsonStr(pager);
    }

    @Override
    public boolean add(ThemeModel model) {
        return dao.addObject("theme.insert", model);
    }

    @Override
    public ThemeModel getInfoById(String s) {
        ThemeModel model = null;
        model = (ThemeModel) dao.queryObject("theme.getInfoById", s);
        return model;
    }

    @Override
    public int edit(ThemeModel model) {
        return dao.updateObject("theme.update", model);
    }

    @Override
    public int delete(String ids) {
        String[] id_array = ids.split(",");
        int num = 0;
        for (String id : id_array) {
            dao.deleteObject("theme.delete", id);
            num++;
        }
        return num;
    }
}
